package javase2.day04;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Demo1 {
	public static void main(String[] args){
		String src = "/home/tarena/hotel.txt";
		String dst = "/home/tarena/new.txt";
		long time=System.currentTimeMillis();
		cp(src, dst);
		long time2 =System.currentTimeMillis();
		System.out.println(time2-time);
	}
	
	public static void cp(String src,String dst){
		try{
			InputStream in = new FileInputStream(src);
			OutputStream out = new FileOutputStream(dst);
			int count;
			byte[] buf = new byte[1024*512];
			while((count=in.read(buf))!=-1){
				out.write(buf,0,count);
			}
			in.close();
			out.close();
		}catch(IOException e){
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}
}
